Skip to content

Fix FSDirectory stale-file race and re-enable crash regression test - #1

Draft
vwilson wants to merge 3 commits into
masterfrom
894
Draft

Fix FSDirectory stale-file race and re-enable crash regression test#1
vwilson wants to merge 3 commits into
masterfrom
894

Conversation

@vwilson

@vwilson vwilson commented May 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Flush FSIndexOutput’s managed FileStream buffer before marking the file stale for Sync().
  • Add a regression test that observes the file length at stale-mark time to cover the race.
  • Re-enable TestIndexWriterOnJRECrash.TestNRTThreads_Mem and make CheckIndexes() dispose the wrapper safely without leaking the directory.

Testing

  • Ran Lucene.Net.Store.TestDirectory in src/Lucene.Net.Tests._J-S successfully.
  • Ran TestIndexWriterOnJRECrash.TestNRTThreads_Mem in src/Lucene.Net.Tests._I-J successfully, including the forked crash path.

@vwilson

vwilson commented May 2, 2026

Copy link
Copy Markdown
Owner Author

@codex review this please

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@vwilson

vwilson commented May 3, 2026

Copy link
Copy Markdown
Owner Author

@claude review

GetTargetPlatform() returned "x64" on any 64-bit process, which on Apple
Silicon (and other ARM64 hosts) caused the forked vstest to abort with
"Could not find 'dotnet' host for the 'X64' architecture". The fork
never connected back to the parent's TCP listener, so the parent blocked
forever in WaitForProcessId until the assembly Timeout fired.

Detect the architecture via RuntimeInformation.ProcessArchitecture so
the fork runs in the same architecture as the parent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
FSDirectory.FSIndexOutput.Dispose:
- Collapse the nested try blocks to two levels (per review).
- Document why upstream Java has no flush race (RandomAccessFile.write
  is unbuffered, unlike FileStream's managed buffer).
- Make Dispose run-once via an atomic Interlocked guard so two racing
  threads can't both run the dispose logic (per review).

TestIndexWriterOnJRECrash fork harness:
- Only pass RunConfiguration.TargetPlatform when running as x86; let
  vstest auto-detect a compatible host on x64/ARM64.
- Add EnsureForkPlatformSupported(): mark the test Inconclusive when the
  32-bit .NET SDK is not installed on x86 (required separately since
  .NET 8) instead of hanging.
- WaitForProcessId no longer blocks forever: poll for connect-back or
  fork exit, and hard-fail with the fork's exit code and captured STDERR
  on startup failure or timeout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants